import React, { useEffect } from 'react';
import { useHistory } from 'react-router';
import { axiosPost } from '../api/request';
import { Provider } from 'react-redux';
import toolkitStore from '../store/toolKit';
import { getAuthentication } from '../utils/authentication';
import { baseFetch } from '../api/request';

// import Pdf from '../component/pdf'
// pdf-lib
// import PdfLib from '../component/pdf/PdfLib'
// react-pdf-highlighter
import PdfHightlighter from '../component/pdf/PdfHightlighter';

export default function Job() {
  const history = useHistory();

  useEffect(() => {
    // fetch('/nestApi/user/getPermission', {
    //   method: 'post',
    //   body: JSON.stringify(getAuthentication())
    // }).then(res => res.json())
    // .then(res => {
    //   if(res.code !== 0 ) history.push('/')
    // })
    // .catch(rej => history.push('/'))

    baseFetch
      .POST('/nestApi/user/getPermission', {
        method: 'post',
        body: JSON.stringify(getAuthentication())
      })
      .then(res => res.json())
      .then(res => {
        if (res.code !== 0) history.push('/');
      })
      .catch(rej => history.push('/'));

    console.log('getAuthentication', JSON.stringify(getAuthentication()));
  }, []);

  return (
    <div className='my__component__wrapper'>
      <Provider store={toolkitStore}>
        Job Page
        {/* <Pdf /> */}
        {/* <PdfLib /> */}
        <PdfHightlighter />
      </Provider>
    </div>
  );
}
